#probe ID        refseq ID       Gene Symbol     log2 FC values (against preadip)
#ILMN_1735045    NM_017436       A4GALT  "0.040365, -0.15992, 0.063337, 0.25641, 0.44225, 0.89837"

import sys

"""
var ch = {ADCH:[{name:'NM_001003684', data:[0.058872, 0.16703, 0.1189, 0.124, 0.094661, 0.63558]},
{name:'NM_013387', data:[-0.088998, -0.045791, -0.073643, -0.045285, 0.086565, 0.094477]},
{name:'NM_013387', data:[0.070917, 0.16415, 0.27671, 0.11552, 0.26926, 0.2989]}]};
"""

gf = open("SGBS_GenesLFC.txt", "r")
out = open("expression_changes.js", "w")

ec_dic = {}

for l in gf.readlines():
	ec_arr = []
	tk = l.strip().split("\t")
	gene = tk[2]
	probe = tk[0]
	name = tk[1]
	data = []
	tka = tk[3].strip().split(",")
	for a in tka:
		data.append(float(a))
	if (ec_dic.get(gene) != None):
		ec_arr = ec_dic.get(gene)
	if (len(tk) < 4):
		print "error"		
		sys.exit
	rec = {}
	rec["name"] = name
	rec["probe"] = probe
	rec["data"] = data
	ec_arr.append(rec)
	ec_dic[gene] = ec_arr
gf.close()

out.write("var ec_dic = " + str(ec_dic) + ";\n")

#A4GALT  0.040365, -0.15992, 0.063337, 0.25641, 0.44225, 0.89837
#A4GNT   0.088388, -0.017695, 0.027588, -0.011051, -0.013554, 0.0053847
